package com.hnqcgczy.ssy.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class MyConnection extends IConnection{
    static {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    @Override
    public Connection getConnMysql() throws SQLException {
        String url="jdbc:mysql://localhost:3306?useSSL=false&serverTimezone=Hongkong&characterEncoding=utf-8&autoReconnect=true";
        Connection conn=DriverManager.getConnection(url,"root","123456");
        return conn;
    }

    @Override
    public Connection getConnOracle() throws SQLException {
        return null;
    }

    public static void main(String []args) {
        Connection connByMysql = null;
        try {
            connByMysql = new MyConnection().getConnMysql();
            System.out.println(connByMysql.isClosed());
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}